<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
    <input onclick="timer(this,5);" type="button" value="发送短信" class="btn"/></p>
    <script>
        function sendmessage(obj,second){
            if (sendmessage) {
                countDown(obj,second)
            }
            else{
                alert("错误")
            }
        }
        function countDown(obj,second){
            if (second>=0) {
                if (typeof buttonDefaultValue ==='undefined') {
                    buttonDefaultValue = obj.defultValue;
                }
                obj.disabled=ture;
                obj.value=buttonDefaultValue;
                second--;
                setTimeout(function(){
                    countDown(obj,second);
                },1000);
            }else{
                  obj.disabled=false;
                  obj.value=buttonDefaultValue;
                }
            }
        
    </script>
</body>
</html>